//
//  HLBaseController.swift
//  weibo-snh
//
//  Created by 黄力 on 15/12/14.
//  Copyright © 2015年 HLTest. All rights reserved.
//

import UIKit

class HLBaseController: UITableViewController,VisitorLoginViewDelegate {
    
    var visitorLoginView: HLVisitorLoginView?
    
    //纯代码创建控制时调用该方法设置view
    //调用该方法后,xib,sb记载view失效
    override func loadView() {
        //登录状态
        let loginStatus: Bool = HLUserAccountViewModel().loginStatus
        //根据登录状态来判断显示的view
        if loginStatus {
            super.loadView()
        }else {
            visitorLoginView = HLVisitorLoginView()
            //设置代理
            visitorLoginView?.delegate = self
            view = visitorLoginView
        }
    }

    override func viewDidLoad() {
        super.viewDidLoad()

    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

}

//VisitorLoginViewDelegate方法

extension HLBaseController {
    //登录
    @objc internal func visitorLogin() {
        print("登录")
        //创建一个OAuth控制器
        let oAuthVC = HLOAuthController()
        //添加导航控制器
        let nav = UINavigationController(rootViewController: oAuthVC)
        //modal到OAuth界面
        presentViewController(nav, animated: true, completion: nil)
    }
    //注册
    @objc internal func visitorRegister() {
        print("注册")
    }
    
}
